define(["jquery","layuiall","zTree","jqform","helper"],function ($,layui,zTree,jqform,helper) {
    controller = {
        site:function () {
            jqform.init()
            $("#test1").click(function () {
                uploadFiles({
                    url: '/admin/webupload/webuploader/multi/1/filetype/image/app/admin/tab/local',
                    file:function (res) {
                        var file = JSON.parse(res);
                        $("#app-photo").find("input[name='site_info[photo]']").val(file[0].filepath);
                        $("#app-photo").find("img").attr("src",file[0].preview_url);
                        localStorage.removeItem("upload");
                    }
                });
            })
            $("#test2").click(function () {
                uploadFiles({
                    url: '/admin/webupload/webuploader/multi/1/filetype/image/app/admin/tab/local',
                    file:function (res) {
                        var file = JSON.parse(res);
                        $("#app-photos").find("input[name='site_info[official]']").val(file[0].filepath);
                        $("#app-photos").find("img").attr("src",file[0].preview_url);
                        localStorage.removeItem("upload");
                    }
                });
            })
        },
        systemsetting:function () {
            $("#qq").click(function () {
                uploadFiles({
                    url: '/admin/webupload/webuploader/multi/1/filetype/image/app/admin/tab/local',
                    file:function (res) {
                        var file = JSON.parse(res);
                        $("#qq-table").find("input[name='system[qqCode]").val(file[0].filepath);
                        $("#qq-table").find("img").attr({"src":file[0].preview_url});
                        localStorage.removeItem("upload");
                    }
                });
            })
            $("#wechat").click(function () {
                uploadFiles({
                    url: '/admin/webupload/webuploader/multi/1/filetype/image/app/admin/tab/local',
                    file:function (res) {
                        var file = JSON.parse(res);
                        $("#wechat-table").find("input[name='system[wechatCode]").val(file[0].filepath);
                        $("#wechat-table").find("img").attr({"src":file[0].preview_url});
                        localStorage.removeItem("upload");
                    }
                });
            })

            jqform.init()
        },
        clearcache:function () {
            //倒计时关闭
            function daojishi(seconds,obj){

                if (seconds > 1){

                    seconds--;

                    $(obj).html('<span class="seconds">'+seconds+'</span>'+"秒后自动关闭 ");

                    setTimeout(function(){
                        daojishi(seconds,obj);
                    },1000);

                }else {
                    history.go("-1")
                }
            }
            daojishi(3,".close-time")
        },
        upload:function () {
            jqform.init()
        },
        download_setting:function () {
            jqform.init()
            $("#test2").click(function () {
                uploadFiles({
                    url: '/admin/webupload/webuploader/multi/1/filetype/image/app/admin/tab/local',
                    file:function (res) {
                        var file = JSON.parse(res);
                        $("#app-photos").find("input[name='watermark']").val(file[0].filepath);
                        $("#app-photos").find("img").attr("src",file[0].preview_url);
                        localStorage.removeItem("upload");
                    }
                });
            })
        },
    }
    return controller;
})